home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d8 / pdriver5.arc / NI9210.ASM < prev    next >
Assembly Source File  |  1989-12-17  |  5KB  |  197 lines

  1. version    equ    0
  2.  
  3.     include    defs.asm
  4.  
  5. ;Ported from Tim Krauskopf's micnet.asm, an assembly language
  6. ;driver for the MICOM-Interlan NI5210, by Russell Nelson.  Any bugs
  7. ;are due to Russell Nelson.
  8. ;Updated to version 1.08 Feb. 17, 1989 by Russell Nelson.
  9. ;Updated to support 1500 byte MTU April 27, 1989 By Brad Clements.
  10. ;Mangled to become a NI9210 driver, September 1989 by Russell Nelson
  11.  
  12. ;  Copyright, 1988, 1989, Russell Nelson
  13.  
  14. ;   This program is free software; you can redistribute it and/or modify
  15. ;   it under the terms of the GNU General Public License as published by
  16. ;   the Free Software Foundation, version 1.
  17. ;
  18. ;   This program is distributed in the hope that it will be useful,
  19. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ;   GNU General Public License for more details.
  22. ;
  23. ;   You should have received a copy of the GNU General Public License
  24. ;   along with this program; if not, write to the Free Software
  25. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  
  27. code    segment    byte public
  28.     assume    cs:code, ds:code
  29.  
  30. ;
  31. ;  Equates for controlling the MICOM board
  32. ;
  33. ;  I/O addresses, writing anything in AL trips these gates
  34. ;
  35. ;  First six addresses are the EPROM board Ether address (read)
  36. ;
  37. IORESET    EQU    0            ; reset the board
  38. IOCA    EQU    2            ; execute command which is in SCB
  39. IODIS    EQU    4            ; disable network connect
  40. IOENA    EQU    6            ; enable network
  41.  
  42. BUS_TYPE    equ    0        ; 16 bit bus type in scb.
  43. BASE_OFFSET    equ    0        ; board's memory starts at zero.
  44. GET_ADDR_INC    equ    2        ; increment the I/O address by two.
  45.  
  46. ;
  47. ;  Data segment
  48. ;
  49.  
  50.     public    int_no
  51. int_no        db    2,0,0,0        ; interrupt number. 
  52. io_addr        dw    0360h,0        ; I/O address for card (pos)
  53. base_addr    dw      0d000h,0    ; base segment for board (pos)
  54.  
  55.     public    driver_class, driver_type, driver_name
  56. driver_class    db    1        ;from the packet spec
  57. driver_type    db    11        ;from the packet spec
  58. driver_name    db    "NI9210",0    ;name of the driver.
  59.  
  60. lbca:
  61. doca:
  62. ;we may be called from places in which ds is unknown.
  63.     assume    ds:nothing
  64.     loadport
  65.     setport    IOCA
  66.     out    dx,al            ; send it
  67.     ret
  68.     assume    ds:code
  69. ;yet, we really should assume ds==code for the rest of this stuff.
  70.  
  71. ;
  72. ; Here we include the code that is common between 82586 implementations.
  73. ; Everything above this is resident.
  74.     include    82586.asm
  75. ; Everything below this is discarded upon installation.
  76.  
  77.     public    usage_msg
  78. usage_msg    db    "usage: ni9210 <packet_int_no> <int_no> <io_addr> <base_addr>",CR,LF,'$'
  79.  
  80.     public    copyright_msg
  81. copyright_msg    db    "Packet driver for the MICOM-Interlan NI9210, version ",'0'+majver,".",'0'+version,".",'0'+i82586_version,CR,LF
  82.         db    "Portions Copyright 1988 The Board of Trustees of the University of Illinois",CR,LF,'$'
  83.  
  84. IRQ_MASK    equ    06h
  85. IRQ_TABLE    db    9            ; Interrupt Value 0
  86.         db    10            ; Interrupt Value 1
  87.         db    11            ; Interrupt Value 2
  88.         db    3            ; Interrupt Value 3
  89.  
  90. check_board:
  91. ;The following code to read the POS registers is courtesy of Racal-Interlan.
  92.  
  93. ; channel selector resides at io 96h
  94. ; POS register base is at io 100h
  95. ; 9210 ID is 0DF0Fh
  96.  
  97. ; search thro' the slots for a 9210 card
  98.     mov    cx, 8            ; for all channels(slots)
  99.  
  100. ; channel select value for slots 0,1,2.. is 8,9,A etc
  101. ; start with slot 0, and then 7,6,5,4,3,2,1
  102. get_05:
  103.     mov    ax, cx            ; channel number
  104.     or    ax, 08h            ; reg. select value
  105.     mov    dx, 96h            ; channel select register
  106.     out    dx, al            ; select channel
  107.  
  108. ; read adapter id
  109.     mov    dx, 100h
  110.     in    al, dx            ; adapter id - ms byte
  111.     mov    ah, al
  112.     inc    dx
  113.     in    al, dx            ; adapter id - ls byte
  114.  
  115. ; Check if 9210
  116.     cmp    ax, 0DF0Fh
  117.     je    get_10
  118.     loop    get_05
  119.  
  120.     mov    dx,offset no_9210_msg
  121.     jmp    error
  122.  
  123. get_10:
  124. ; found our Adapter
  125.  
  126. ; Get Ni9210 I/O Address ( read POS Register 1 )
  127.     xor    ax,ax
  128.     mov    dx,103h
  129.     in    al,dx
  130.     xor    ah,ah
  131.     mov    cl,5
  132.     shl    ax,cl
  133.     mov    io_addr,ax
  134.  
  135. ; Get Ni9210 IRQ ( read POS Register 0 )
  136.     mov    dx,102h
  137.     in    al,dx
  138.     mov    bl,al
  139.     and    bx,IRQ_MASK
  140.     shr    bx,1
  141.     mov    al,IRQ_TABLE[bx]
  142.     mov    int_no,al
  143.  
  144. ; Get Memory Address ( read POS Registers 2 and 3 )
  145.     mov    dx,105h
  146.     in    al,dx
  147.     mov    ah,al
  148.     dec    dx
  149.     in    al,dx
  150.     and    ax,3fe0h
  151.     mov    cl,5
  152.     shl    ax,cl
  153.     mov    base_addr,ax
  154.  
  155.     mov    dx, 102h
  156.     in    al,dx
  157.     or    al,1            ;enable the card.
  158.     out    dx,al
  159.  
  160.     mov    dx, 96h            ;deselect the card.
  161.     xor    al,al
  162.     out    dx,al
  163.  
  164.     mov    dx,io_addr        ; i/o address
  165.     add    dx,EADDR_LEN*GET_ADDR_INC    ; look past the ethernet address.
  166.     in    al,dx
  167.     mov    bl,al            ; assemble pattern to check
  168.     add    dx,GET_ADDR_INC
  169.     in    al,dx
  170.     mov    bh,al
  171.     cmp    bx,05500h        ; pattern known to be there in ROM
  172.     jz    have_9210_io
  173.     pop    dx            ;drop our return address
  174.     mov    dx,offset no_9210_io_msg
  175.     jmp    error
  176. have_9210_io:
  177.  
  178.     mov    ax,base_addr
  179.     mov    cx,2000h        ;test only what we are going to use.
  180.     call    memory_test
  181.     jz    have_9210_mem
  182.     pop    dx            ;drop our return address
  183.     mov    dx,offset no_9210_mem_msg
  184.     jmp    error
  185. have_9210_mem:
  186.     ret
  187.  
  188. no_9210_msg    db    "No 9210 found.",CR,LF,'$'
  189.  
  190.  
  191. no_9210_io_msg    db    "No 9210 found at that I/O address.",CR,LF,'$'
  192. no_9210_mem_msg    db    "No 9210 found at that memory address.",CR,LF,'$'
  193.  
  194. code    ends
  195.  
  196.     end
  197.